
$(function () {


    $(document).on('click','.time-delete',function(){
    	$(this).parent().parent().parent().remove();
    });
    
    $("#first_distance").change(function(){
    	if($(this).val()==""){
    		
    	}
    	$("#overDistance").html($(this).val()+"公里后，每公里收费");
    	$("#over_div").show(500);
    });
    
    var time_index=$("#fieldset-div .form-group").length;
    $(".time-add").click(function(){
			var newitem = '<div class="form-group">'+
				                '<label class="col-sm-3 control-label"></label>'+
				                '<div class="col-sm-5">'+
				                    '<div class="input-group">'+
						            	'<input name="gradientPricingDetails['+time_index+'].distance" class="form-control" type="number" min="0" required/>'+
						            	'<span class="input-group-addon">公里内，每公里收费</span>'+
						            	'<input name="gradientPricingDetails['+time_index+'].money" class="form-control" type="number" min="0" required/>'+
						            	'<span class="input-group-addon">元</span>'+
					                '</div>'+
				                '</div>'+
				                '<span class="help-block"><small><a href="javascript:;" class="time-delete">删除</a></small></span>'+
				            '</div>';
    	
    	$("#fieldset-div").append(newitem);
    	time_index++;
    	
    });
    
});


